package com.web.base.log.dao;

import com.blue.jdbc.BaseDao;
import com.web.base.log.model.Message;
import org.springframework.stereotype.Repository;

/**
 * 消息数据库访问
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2018年06月20日
 */
@Repository("logMessageDao")
public class MessageDao extends BaseDao<Message>
{
	public MessageDao()
	{
	}
	
	@Override
	protected void query(StringBuilder sql, Message param)
	{
		if (param != null)
		{
			if (param.getSenderId() != null)
				sql.append(" and a.sender_id=:senderId");
				
			if (param.getReceiverId() != null && param.getReceiverId() > 0)
				sql.append(" and a.receiver_id=:receiverId");
				
			if (param.getRead() != null)
				sql.append(" and a.read=:read");
				
		}
		sql.append(" order by a.id desc");
	}
	
}
